﻿using BaseHeightControl;
using CommunityToolkit.Mvvm.ComponentModel;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace HeightControlAssistanceProgram
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        TakeOneBuilding takeOneBuilding = new TakeOneBuilding();
        public MainWindow()
        {
            InitializeComponent();

            
            takeOneBuilding.ReBackData_InTake+= TakeOneBuilding_ReBackDatas;
            this.DataContext = takeOneBuilding;

        }

        private void TakeOneBuilding_ReBackDatas(string Msg)
        {
            //


            if (Msg.Contains("楼层控制面板打开"))
            {
                int bodyIndex = -1;
                for (int i = 0; i < takeOneBuilding._OneBuilding.BoxBodies.Count; i++)
                {
                    if (takeOneBuilding._OneBuilding.BoxBodies[i].Name == Msg.Split(',')[0])
                    {
                        bodyIndex = i;
                        break;
                    }
                }

                Window_FloorControl window_FloorControl = new Window_FloorControl();
                window_FloorControl.Floors = takeOneBuilding._OneBuilding.Floors;
                window_FloorControl.DataContext = takeOneBuilding._OneBuilding.BoxBodies[bodyIndex];
                window_FloorControl.Show();
            }
            else if (Msg.Contains("在楼层控制面板中点击了"))
            {
                MessageBox.Show(Msg);
            }
            else
            {
                MessageBox.Show(Msg);
            }
                
        }
    }


}